﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.WindowsAzure.ServiceRuntime;
using System.Configuration;

namespace AzureLibrary
{
    public class ConfigurationHelper
    {
        //TODO - need to be able to choose between normal config and azure - abstract out? Has be to be used in Common
        public static string EntityFrameworkConnectionString
        {
            get
            {
                try
                {
                    if (RoleEnvironment.IsAvailable)
                    {
                        string entityFrameworkConnectionString = RoleEnvironment.GetConfigurationSettingValue("EntityFrameworkConnectionString");
                        return entityFrameworkConnectionString;
                    }
                    else
                    {
                        string entityFrameworkConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["communergyEntities"].ConnectionString;
                        return entityFrameworkConnectionString;
                    }
                }
                catch
                {
                    return null;
                }
                
            }
        }

        private static string ConfigurationManager(string p)
        {
            throw new NotImplementedException();
        }
    }
}
